import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EmailConfigVO, EmailConfigForm, EmailConfigQuery } from '@/api/system/EmailConfig/types';

/**
 * 查询订单邮件配置列表
 * @param query
 * @returns {*}
 */

export const listEmailConfig = (query?: EmailConfigQuery): AxiosPromise<EmailConfigVO[]> => {
  return request({
    url: '/system/EmailConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询订单邮件配置详细
 * @param configId
 */
export const getEmailConfig = (configId: string | number): AxiosPromise<EmailConfigVO> => {
  return request({
    url: '/system/EmailConfig/' + configId,
    method: 'get'
  });
};

/**
 * 新增订单邮件配置
 * @param data
 */
export const addEmailConfig = (data: EmailConfigForm) => {
  return request({
    url: '/system/EmailConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改订单邮件配置
 * @param data
 */
export const updateEmailConfig = (data: EmailConfigForm) => {
  return request({
    url: '/system/EmailConfig',
    method: 'put',
    data: data
  });
};

/**
 * 删除订单邮件配置
 * @param configId
 */
export const delEmailConfig = (configId: string | number | Array<string | number>) => {
  return request({
    url: '/system/EmailConfig/' + configId,
    method: 'delete'
  });
};
